import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
} from '@nestjs/common'
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger'
import { MenuService } from './menu.service'
import { CreateMenuDto } from './dto/create-menu.dto'
import { UpdateMenuDto } from './dto/update-menu.dto'

@ApiBearerAuth()
@ApiTags('菜单管理')
@Controller('menu')
export class MenuController {
  constructor(private readonly menuService: MenuService) {}

  @ApiOperation({ summary: '创建菜单' })
  @Post()
  create(@Body() createMenuDto: CreateMenuDto) {
    return this.menuService.create(createMenuDto)
  }

  @ApiOperation({ summary: '查找所有菜单' })
  @Get()
  findAll() {
    return this.menuService.findAll()
  }

  @ApiOperation({ summary: '查找单个菜单' })
  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.menuService.findOne(id)
  }

  @ApiOperation({ summary: '更新菜单' })
  @Patch(':id')
  update(@Param('id') id: string, @Body() updateMenuDto: UpdateMenuDto) {
    return this.menuService.update(id, updateMenuDto)
  }

  @ApiOperation({ summary: '删除菜单' })
  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.menuService.remove(id)
  }
}
